﻿<%@ Control Language="C#" Inherits="System.Web.Mvc.ViewUserControl<dynamic>" %>
<%@ Import Namespace="VietPublisher.BaseProject.Utils.Miscellaneous" %>
<%@ Import Namespace="VietPublisher.BaseProject.Models.cart" %>
<%@ Register Src="User_Login.ascx" TagName="Flogin" TagPrefix="UcLogin" %>
<%
    
    string userName = string.Empty;
    if (Session[DConst.userName] != null)
    {
        userName = Session[DConst.userName].ToString();
    }

    int cartNum = 0;
    if (Session[DConst.sessionCart] != null)
    {
        Cart cart = (Cart)Session[DConst.sessionCart];
        cartNum = cart.items.Count;
    }
    
%>
<div>
    <div id="hdLogo">
        <img src="../../Content/image/Logo_Admin.png" />
    </div>
    <div id="hdRight">
        <div class="menuHeader Clearfix">
            <div style="float: right; width: 110px; position:fixed; z-index:2003; margin-left:430px">
                <span><a href="/Home/Cart">
                    <img src="../../Content/image/icon/icon_cart.png" title="View Items in my cart" />
                </a><a href="/Home/Cart" title="View Items in my cart" style="color:red;">My Cart (<%=cartNum%>)</span>
                </a>
            </div>
            <div style="float: right; margin:5px 130px 5px 5px;" class="login" id="login">
                <span><a>
                    <%= string.IsNullOrEmpty(userName) ? "" : "Welcome " + Session[DConst.userName].ToString()%></a></span>
                <span>Login</span>
                <div class="fromLogin">
                    <UcLogin:Flogin ID="Flogin" runat="server" />
                </div>
                <a href="/Account/Create">SignUp</a>
                <%if (!string.IsNullOrEmpty(userName))
                  { %>
                <a href="javascript:logOut();">Logout </a>
                <%} %>
            </div>
        </div>
        <div class="hdSearch Clearfix">
            <form action="">
            <table>
                <tr>
                    <td class="tdInputsearch">
                        <input type="text" onclick="" name="txtSearch" value="Search...." id="txtSearch" />
                    </td>
                    <td class="bntSearch">
                        <button type="submit">
                            Search</button>
                    </td>
                </tr>
            </table>
            </form>
        </div>
    </div>
</div>
<script type="text/javascript">




        //reload User_Header (user control)
        function reloadLogon(){
            //todo reloadLogon
            $("#header").load("/Home/ReloadLogon");
        }

        function logOut() {           
            window.location = "/Home/LogOff";
        }    

        function clearText() { 
        // clear text search tren text box
        }

     <%--Menu main--%>
  var statusCloseSubMenu = "1";
        $(document).ready(function () {          

                 $("div.login span").click(function() { 
		                
                        window.setTimeout("onClickDelay()", 500);

                        if(statusCloseSubMenu == "0")
                        {
                            $(this).parent().find("div.fromLogin").slideUp('slow').show();
                            statusCloseSubMenu = "1";
                        }
                        else{
		                $(this).parent().find("div.fromLogin").slideDown('slow').show(); 
                        statusCloseSubMenu = "0";
                        }
		                $(this).parent().hover(function() {}, function(){//$(this).parent().find("div.fromLogin").slideUp('slow'); //When the mouse hovers out of the subnav, move it back up
                        });

		                //Following events are applied to the trigger (Hover events for the trigger)
		                }).hover( function() { $(this).addClass("subhover");}, function(){ $(this).removeClass("subhover"); });

                               

        });



function onClickDelay() {
        statusCloseSubMenu = "0";
    }
       

    <%--end menu main--%>


</script>
